function countChange (money) {
    return cc(money, 5)
}

const record = {}
function cc (money, kindCount) {
    return ccIter(money, kindCount, 0, 1)
}

function ccIter (money, kindCount, moneyIndex, kindIndex) {
    const right = moneyIndex - firstDenomination(kindIndex) === 0 ? 1 : (record[`${moneyIndex - firstDenomination(kindIndex)}:${kindIndex}`] || 0)
    console.log(record, moneyIndex, kindIndex)
    if (moneyIndex === 0) record[`${moneyIndex}:${kindIndex}`] = 1
    else record[`${moneyIndex}:${kindIndex}`] = (record[`${moneyIndex}:${kindIndex - 1}`] || 0) + (right < 0 ? 0 : right)
    if (moneyIndex < money) return ccIter(money, kindCount, ++moneyIndex, kindIndex)
    if (kindIndex < kindCount) return ccIter(money, kindCount, 1, ++kindIndex)
    if (moneyIndex === money && kindCount === kindIndex) return record[`${moneyIndex}:${kindIndex}`]
}

const DENOMINATION_MAP = {
    1: 1,
    2: 5,
    3: 10,
    4: 25,
    5: 50
}
function firstDenomination (kindIndex) {
    return DENOMINATION_MAP[kindIndex]
}